﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using ControleRepresentante.Logic.Models;
using WebSite.ViewModels.EditViewModels.EditGridViewModels;

namespace WebSite.ViewModels.EditViewModels
{
    public abstract class DetailsHolderEditViewModel : AttributeHolderEditViewModel
    {
        protected DetailsHolderEditViewModel(string title, string message = null)
            : base(title, message)
        {
        }

        protected virtual IEditGridViewModel GetEnderecoEditGridViewModel(HtmlHelper htmlHelper, DetailsHolder detailsHolder)
        {
            return new EnderecoEditGridViewModel(htmlHelper, ControllerName, detailsHolder);
        }

        protected override IEnumerable<TabItem> GetTabs(HtmlHelper htmlHelper)
        {
            List<TabItem> result = base.GetTabs(htmlHelper).ToList();

            DetailsHolder detailsHolder = (DetailsHolder)Model;

            result.Add(new TabItem("Contatos",
                "~/Content/contacts.png",
                new ContatoEditGridViewModel(htmlHelper, ControllerName, detailsHolder)));
            
            result.Add(new TabItem("Endereços",
                "~/Content/address.png",
                GetEnderecoEditGridViewModel(htmlHelper, detailsHolder)));

            result.Add(new TabItem("Contas",
                "~/Content/bank.png", 
                new ContaEditGridViewModel(htmlHelper, ControllerName, detailsHolder)));

            return result;
        }
    }
}